<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>中间品信息编辑</title>
    {% include 'system/common/header.html' %}
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item layui-hide">

                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{ info.id }}" name="id" lay-verify="title"
                               autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">品名</label>
                    <div class="layui-input-block">
                        <input type="text" name="品名" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.品名 }}" >
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label class="layui-form-label">默认规格</label>
                    <div class="layui-input-block">
                        <input type="text" name="默认规格" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.默认规格 }}" >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">默认产地</label>
                    <div class="layui-input-block">
                        <input type="text" name="默认产地" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.默认产地 }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">代码</label>
                    <div class="layui-input-block">
                        <input type="text" name="代码" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.代码 }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">执行标准</label>
                    <div class="layui-input-block">
                        <input type="text" name="执行标准" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.执行标准 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">检验标准</label>
                    <div class="layui-input-block">
                        <input type="text" name="检验标准" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.检验标准 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="状态" value="1" title="开启" {% if info.状态 == 1 %} } checked{% endif %}>
                        <input type="radio" name="状态" value="0" title="关闭" {% if info.状态 == 0 %} } checked{% endif %}>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">版本号</label>
                    <div class="layui-input-block">
                        <input type="text" name="版本号" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.版本号 }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">归属类别</label>
                    <div class="layui-input-block">
                        <input type="text" name="归属类别" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.归属类别 }}">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">贮存条件</label>
                    <div class="layui-input-block">
                        <input type="text" name="贮存条件" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.贮存条件 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">药典贮存条件</label>
                    <div class="layui-input-block">
                        <input type="text" name="药典贮存条件" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.药典贮存条件 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" name="备注" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.备注 }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">质量要求</label>
                    <div class="layui-input-block">
                        <input type="text" name="质量要求" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.质量要求 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">保质期</label>
                    <div class="layui-input-block">
                        <input type="text" name="保质期" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.保质期 }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">养护内容</label>
                    <div class="layui-input-block">
                        <input type="text" name="养护内容" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                               class="layui-input" value="{{ info.养护内容 }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">对应成品</label>
                    <div class="layui-input-block">
                        <select lay-search="" id="select-finished" name="成品_id">
                              <option value="{{ info.成品_id }}">{{ info._成品表.品名 }}{{ info._成品表.代码 }}</option>
                            </select>
                    </div>
                </div>



            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-update">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
{% include 'system/common/footer.html' %}
<script>
    layui.use(['form', 'jquery', 'dtree'], function () {
        let form = layui.form
        let $ = layui.jquery
        let dtree = layui.dtree
        var laydate = layui.laydate;
         // 获取成品信息
            $.ajax({
                url: '/goodsfiles/intermediate/yp/finished',
                data: '',
                dataType: 'json',
                contentType: 'application/json',
                type: 'get',
                success: function (result) {

                    var select=document.getElementById('select-finished')
                    var options=result

                    options.forEach(function (option) {
                        var opt=document.createElement('option');
                        opt.value=option.value;
                        opt.text=option.text;
                        select.appendChild(opt);

                    })
                    form.render('select')

                },

            });
          // 渲染
         laydate.render({
            elem: '#ID-laydate-demo'
          });

        form.on('submit(user-update)', function (data) {

            $.ajax({
                url: '/goodsfiles/intermediate/yp/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                            parent.layui.table.reload('user-table')
                        })
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000})
                    }
                }
            })
            return false
        })
    })
</script>
</body>
</html>